//
//  UIView+Swizzing.m
//  001-消息转发机制
//
//  Created by hzg on 2018/4/26.
//  Copyright © 2018年 tz. All rights reserved.
//

#import "UIView+Swizzing.h"
#import <objc/runtime.h>

@implementation UIView (Swizzing)

+ (void)load {
    Method m1 = class_getInstanceMethod([self class], @selector(setBackgroundColor:));
    Method m2 = class_getInstanceMethod([self class], @selector(gv_setBackgroundColor:));
    method_exchangeImplementations(m1, m2);
}

- (void) gv_setBackgroundColor:(UIColor*) color {
    if (color == [UIColor blackColor]) {
        [self gv_setBackgroundColor:[UIColor redColor]];
    }
}


@end
